import React, { Component } from 'react'
import PubSub from 'pubsub-js'
import './index.css'

export default class School extends Component {
	state = {name:'尚硅谷'}
	render() {
		return (
			<div className="school">
				<h2>我是School组件，学校名：{this.state.name}</h2>
				<button onClick={this.sendSchoolName}>把学校名传给Weather组件</button>
			</div>
		)
	}
	sendSchoolName = ()=>{
		//发布消息
		PubSub.publish('peiqi',this.state.name)
	}
}
